Skip to content

Comments

Performance improvements#93

Merged
voneiden merged 5 commits intomainfrom
perf
Jan 27, 2026
Merged

Performance improvements#93
voneiden merged 5 commits intomainfrom
perf

Conversation

@voneiden
Copy link
Contributor

@voneiden voneiden commented Jan 23, 2026

Locally I get 1000 addresses in 430 ms with municipalitycode=091. main branch yields 4180 ms. https://paikkatietohaku.api.test.hel.ninja yields 45000 ms.

Review/dev DB:s seem to be empty so can't test this 😒

edit: a bit of hacking around and got 6740 ms for review, 51690 ms for dev

If DEBUG and DEBUG_TOOLBAR are set, django-debug-toolbar will be enabled
and configured.

Refs: RATYK-156
On large tables DISTINCT tends to result in a heavy operation with
Django. The intention is to remove duplicate rows that can result from
filtering via many-to-many relations. This can usually be worked around
and in this case we can manually prefetch id numbers to avoid expensive
JOINS against the address table.

Refs: RATYK-156
These were originally added to work around bugs in earlier Postgres
versions. Presumably should not happen anymore.

They seem to have a small performance cost.

Refs: RATYK-156
Removes a lot of duplicate queries from endpoints
by setting appropriate select_related and
prefetch_related.

Refs: RATYK-156
@azure-pipelines
Copy link

PAIKKATIETOHAKU-API branch is deployed to platta: https://paikkatietohaku-api-pr93.api.dev.hel.ninja 🚀🚀🚀

@azure-pipelines
Copy link

PAIKKATIETOHAKU-API branch is deployed to platta: https://paikkatietohaku-api-pr93.api.dev.hel.ninja 🚀🚀🚀

@voneiden voneiden marked this pull request as ready for review January 27, 2026 09:51
@voneiden voneiden requested a review from a team as a code owner January 27, 2026 09:51
@azure-pipelines
Copy link

PAIKKATIETOHAKU-API branch is deployed to platta: https://paikkatietohaku-api-pr93.api.dev.hel.ninja 🚀🚀🚀

The index includes all the fields that the address rest endpoint uses
which result in very fast index-only scans.

refs: RATYK-156
@sonarqubecloud
Copy link

@azure-pipelines
Copy link

PAIKKATIETOHAKU-API branch is deployed to platta: https://paikkatietohaku-api-pr93.api.dev.hel.ninja 🚀🚀🚀

@voneiden voneiden merged commit 4fb5f8c into main Jan 27, 2026
26 checks passed
@voneiden voneiden deleted the perf branch January 27, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants